package com.qf.controller.advice;

import com.qf.dto.R;
import com.qf.exception.MyException;
import com.qf.utils.ResultCode;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/*
 *  @author Administrator
 *  @version V1.0
 *  @Project smartdeviceplatgorm
 *  @Package com.qf.controller.advice
 *  @Description
 *  @Date2022/3/17 0017 11:00
 */
@RestControllerAdvice
public class MyErrorAdvice {

    @ExceptionHandler(MyException.class)
    public R myException(MyException e) {
        e.printStackTrace();
        return R.getR(ResultCode.FAIL, e.getMessage(), null,null);
    }

    @ExceptionHandler(Exception.class)
    public R processMyBaseException(Exception e) {
        e.printStackTrace();
        return R.getR(ResultCode.FAIL, "网络故障,请检查网络", null,null);
    }
}
